<?php
/**
 * User: Kris
 * Date: 2/5/12
 */

class MediaSearch extends SearchResult
{
    public function __construct($em, $searchString)
    {
        parent::__construct($em);
        $this->resultsPerPage = 2;
        $this->resultQuery = $this->em->createQuery("SELECT m, p FROM Media m JOIN m.post p WHERE m.description LIKE :mediaDescription ORDER BY m.id DESC");
        $this->resultQuery->setMaxResults($this->resultsPerPage);
        $this->resultQuery->setParameter('mediaDescription', '%' . $searchString . '%');

        $this->countQuery = $this->em->createQuery("SELECT COUNT(m) FROM Media m WHERE m.description LIKE :mediaDescription");
        $this->countQuery->setParameter('mediaDescription', '%' . $searchString . '%');
    }

}
